home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: August 14, 1996
- // Author: ms
- //
- // Description:
- // Make a popup for all the fonts available
- //
- // Input Arguments:
- // The layout.
- //
- // Return Value:
- // None.
- //
-
- proc string fontTypeName( string $fName )
- {
- string $name = "";
- string $all[];
- tokenize( $fName, "-", $all );
- if( size($all) > 1 ) {
- $name = $all[0];
- }
- return $name;
- }
-
-
- global proc doFontDialog ( string $tabLayout )
- {
- if (`exists Win32Init`)
- {
- string $fName = `fontDialog`;
- if ($fName == "") return;
- resetFontFieldText $tabLayout $fName;
- }
- }
-
- global proc createFontPopup( string $tabLayout, string $fontPopup,
- string $command, string $extraArg )
- {
- int $maxLinesPerScreen = 36;
- string $listOfFonts[] = `fontDialog -FontList`;
-
- int $n = size($listOfFonts);
-
- popupMenu -e -dai $fontPopup;
- setParent -menu $fontPopup;
-
- string $itemName, $fontName;
- if ( $extraArg == "NULL" ) $extraArg = "";
- string $dowhat = ( $command + " " + $extraArg + " " +
- "\"" + $tabLayout + "\" " );
-
- string $currentFontType, $thisFontType, $nextFontType;
- int $i, $cntr, $subs, $moreSubs, $lineCntr;
-
- // Now make the menu popup - go hierarchical for the same type.
- $currentFontType = "";
- $moreSubs = 0;
- $lineCntr = 0;
- $cntr = 0;
- $subs = 0;
-
- // GG - this should be first, because Marking Menus only support 30 items.
- if (`exists Win32Init`) {
- menuItem -c ("doFontDialog " + "\"" + $tabLayout + "\";")
- -l "Select...";
- }
- else {
- // Go through each item in the list:
- for( $i=0; $i<$n; $i+=1 ) {
- $itemName = "SEFM" + string($i);
- $fontName = $listOfFonts[$i];
-
- if (`exists Win32Init`) {
- menuItem -c ($dowhat + "\"" + $fontName + "\";")
- -l $fontName $itemName;
- }
- else {
- // Find out the font type; this is either the string
- // before the "-" or "" if the font name has no "-"
- $thisFontType = fontTypeName( $fontName );
-
- // Find the font type of the next item, if there is one:
- $nextFontType = "";
- if( $i+1 < $n ) {
- $nextFontType = fontTypeName( $listOfFonts[$i+1] );
- }
-
- // If we have something like "Courier" followed by
- // "Courier-Bold" we have to recognize they are in the
- // same group.
- if( ($thisFontType == "") && ($nextFontType == $fontName) ) {
- $thisFontType = $nextFontType;
- }
-
- // If we are already processing this font type, we'll just
- // add the menu item to the list.
- if( $thisFontType == $currentFontType ) {
- if( 0 == $subs ) {
- $lineCntr += 1;
- if( $lineCntr > $maxLinesPerScreen ) {
- $moreSubs += 1;
- menuItem -l "More..."
- -subMenu true
- ("SESMM" + string($moreSubs));
- $lineCntr = 0;
- }
- }
- menuItem -c ($dowhat + "\"" + $fontName + "\";")
- -l $fontName $itemName;
- }
- else {
- // In this case, the font type is different. So, we
- // have to close down the previous sub menu first:
-
- if( $subs > 0 ) {
- $subs -= 1;
- setParent -menu ..;
- }
-
- // How menu total screen lines are we taking:
- $lineCntr += 1;
- if( $lineCntr > $maxLinesPerScreen ) {
- $moreSubs += 1;
- menuItem -l "More..."
- -subMenu true
- ("SESMM" + string($moreSubs));
- $lineCntr = 0;
- }
-
- // If this is the first item of a font type with multiple
- // items, we better start a new sub item.
- if( ($thisFontType != "") &&
- ($thisFontType == $nextFontType)) {
- menuItem -l $thisFontType
- -subMenu true
- ("SESM" + string($cntr));
- $cntr += 1;
- $subs += 1;
- }
-
- // Add the actual menu item; this is either under the above
- // sub menu item, or just on its own.
- menuItem -c ($dowhat + "\"" + $fontName + "\";")
- -l $fontName $itemName;
- $currentFontType = $thisFontType;
- }
- }
- }
-
- for( $i=0; $i<$moreSubs; $i+=1 ) {
- setParent -menu ..;
- }
-
- if( $currentFontType != "" ) {
- $subs -= 1;
- setParent -menu ..;
- }
- }
- }
-
-